package Chapter6.complete;

import java.util.HashSet;
import java.util.Set;

import javax.persistence.AttributeOverride;
import javax.persistence.AttributeOverrides;
import javax.persistence.Column;
import javax.persistence.Embedded;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.ManyToMany;

@Entity
public class AuthorComplete {
	private int id;
	private String name;
	private Set<BookComplete> books = new HashSet<BookComplete>();
	private AuthorAddressComplete address;

	public AuthorComplete() {
	}

	public AuthorComplete(String name, AuthorAddressComplete address) {
		this.name = name;
		this.address = address;
	}

	@Id
	@GeneratedValue
	public int getId() {
		return id;
	}

	public void setId(int id) {
		this.id = id;
	}

	public String getName() {
		return name;
	}

	public void setName(String name) {
		this.name = name;
	}

	@ManyToMany(mappedBy = "authors")
	public Set<BookComplete> getBooks() {
		return books;
	}

	public void setBooks(Set<BookComplete> books) {
		this.books = books;
	}

	@Embedded
	@AttributeOverrides({
			@AttributeOverride(name = "address", column = @Column(name = "ADDR")),
			@AttributeOverride(name = "country", column = @Column(name = "NATION")) })
	public AuthorAddressComplete getAddress() {
		return address;
	}

	public void setAddress(AuthorAddressComplete address) {
		this.address = address;
	}

}
